package com.zhuyuan.database.scope;

/**
 * @Author: 张琳凯
 * @Description: 数据权限类型枚举（定义优先级）
 * @DateTime: 2025/3/3 21:22
 **/
public enum DataScopeType {
    ALL("1", 1,"全部数据权限"),
    CUSTOM("2", 2,"自定数据权限"),
    DEPT_AND_BELOW("4", 3,"部门及以下数据权限"),
    DEPT("3", 4,"部门数据权限"),
    SELF("5", 5,"仅本人数据权限");

    private final String code;
    private final int priority;

    private final String desc;

    DataScopeType(String code, int priority,String desc) {
        this.code = code;
        this.priority = priority;
        this.desc = desc;
    }

    public static DataScopeType parse(String code) {
        for (DataScopeType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效权限类型编码: " + code);
    }

    public int getPriority() {
        return priority;
    }

    public String getCode() {
        return code;
    }
}
